From: Carlos Garnacho Date: Tue, 9 Aug 2022 14:00:33 +0000 (+0200) Subject: misc: Toggle IBus OSK capability on OSK visibility X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~461^2^2~108 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=23bfd08b3c9;p=gnome-shell.git misc: Toggle IBus OSK capability on OSK visibility Newer versions of IBus (> 1.5.26) have the IBUS_CAP_OSK capability which can be used to hint the active IM about an OSK driving input as opposed to a physical keyboard. This may be used by IMs to tweak their behavior to suit OSKs better. Add the GNOME Shell side handling for this capability, and toggle it on whenever the OSK is visible. Since this is a far too new enum value and we don't want such new IBus dependency, this change plays fast and loose with JS guarantees, since a logical OR with an undefined value results in the other operand unmodified it will work for older versions where the capability does not exist and thus we want nothing extra enabled. Part-of: --- diff --git a/js/misc/inputMethod.js b/js/misc/inputMethod.js index 856bf57ae..fba2730bd 100644 --- a/js/misc/inputMethod.js +++ b/js/misc/inputMethod.js @@ -3,6 +3,7 @@ const { Clutter, GLib, Gio, GObject, IBus } = imports.gi; const Keyboard = imports.ui.status.keyboard; +const Main = imports.ui.main; Gio._promisify(IBus.Bus.prototype, 'create_input_context_async', 'create_input_context_async_finish'); @@ -42,6 +43,9 @@ class InputMethod extends Clutter.InputMethod { _updateCapabilities() { let caps = IBus.Capabilite.PREEDIT_TEXT | IBus.Capabilite.FOCUS | IBus.Capabilite.SURROUNDING_TEXT; + if (Main.keyboard.visible) + caps |= IBus.Capabilite.OSK; + if (this._context) this._context.set_capabilities(caps); } @@ -72,10 +76,14 @@ class InputMethod extends Clutter.InputMethod { this._context.connect('forward-key-event', this._onForwardKeyEvent.bind(this)); this._context.connect('destroy', this._clear.bind(this)); + Main.keyboard.connectObject('visibility-changed', () => this._updateCapabilities()); + this._updateCapabilities(); } _clear() { + Main.keyboard.disconnectObject(this); + if (this._cancellable) { this._cancellable.cancel(); this._cancellable = null; diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index ac36f3573..77a6f7d5c 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -1180,8 +1180,10 @@ var Keypad = GObject.registerClass({ } }); -var KeyboardManager = class KeyBoardManager { +var KeyboardManager = class extends Signals.EventEmitter { constructor() { + super(); + this._keyboard = null; this._a11yApplicationsSettings = new Gio.Settings({ schema_id: A11Y_APPLICATIONS_SCHEMA }); this._a11yApplicationsSettings.connect('changed', this._syncEnabled.bind(this)); @@ -1237,6 +1239,7 @@ var KeyboardManager = class KeyBoardManager { if (enabled && !this._keyboard) { this._keyboard = new Keyboard(); this._keyboard.connect('visibility-changed', () => { + this.emit('visibility-changed'); this._bottomDragAction.enabled = !this._keyboard.visible; }); } else if (!enabled && this._keyboard) {